#include <iostream>
#include <utility>
#include <cassert>
using namespace std;
template <class T>
size_t miXXmum_index(T* t, size_t len, bool h = 1)
{
    assert(len > 0);

    size_t m = 0;
    for (size_t i = 1; i < len; i++) {
        if (h){
            if (t[i] < t[m])
                m = i;
        }
        else{
            if (t[i] > t[m])
                m = i;
        }
    }

    return m;
}
template <class T>
void selection_sort(T* t, size_t len, bool h)
{
    size_t start = 0;
    while (true) {
        if (start + 1 == len)
            break;
        size_t m = miXXmum_index(t + start, len - start, h);
        m += start;
        if (m != start) {
            swap(t[start], t[m]);
        }

        start++;
    }
}

int main(){
    bool h;
    cin >> h;
    double a[5];
    for (size_t i = 0; i < 5; i++) {
        cin >> a[i];
    }
    selection_sort(a, sizeof(a)/sizeof(a[0]), h);

    for (size_t i = 0; i < 5; i++) {
        cout << a[i] << " ";
    }
    cout << endl;

}
